var mongoose = require('mongoose');

mongoose.set('useFindAndModify', false)
mongoose.connect('mongodb://localhost/SunRan',{useNewUrlParser: true,useUnifiedTopology:true,});

var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
//构建users的model
var usersSchema = mongoose.Schema({
    username: String,
    password: String,
    Tel:String,
    role:String,

});
let houseSchema = mongoose.Schema({
    position: String,//位置
    resource: String,//房源
    area:String,//面积
    houseType:String,//户型
    state:String,//状态
    picture:String,//照片
    price:String//价格
});
let commentSchema = mongoose.Schema({
    date: String,//日期
    commentUsers: String,//评论用户
    content:String,//内容
    nice:String,//点赞
});
let sellSchema = mongoose.Schema({
    position: String,//位置
    resource: String,//房源
    area:String,//面积
    houseType:String,//户型
    state:String,//状态
    picture:String,//照片
    price:String//价格
});



var Users = mongoose.model('users', usersSchema);
var House = mongoose.model('houses', houseSchema);
var Comment = mongoose.model('comments', commentSchema);
var Sell = mongoose.model('sells', sellSchema);

exports.Users = Users
exports.House = House
exports.Comment = Comment
exports.Sell = Sell